home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1999 May / Cd Pc Users extra 20 mayo 1999.iso / Prog / Inst / MsChart / Mschart2 / FORM1.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1998-05-04  |  5.3 KB  |  189 lines

  1. VERSION 5.00
  2. Object = "{02B5E320-7292-11CF-93D5-0020AF99504A}#1.0#0"; "MSCHART.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Form1"
  5.    ClientHeight    =   4185
  6.    ClientLeft      =   3300
  7.    ClientTop       =   1770
  8.    ClientWidth     =   7275
  9.    LinkTopic       =   "Form1"
  10.    PaletteMode     =   1  'UseZOrder
  11.    ScaleHeight     =   4185
  12.    ScaleWidth      =   7275
  13.    Begin MSChartLib.MSChart Chart1 
  14.       Height          =   3975
  15.       Left            =   1440
  16.       OleObjectBlob   =   "Form1.frx":0000
  17.       TabIndex        =   0
  18.       Top             =   120
  19.       Width           =   5775
  20.    End
  21.    Begin VB.CommandButton CmdGraph 
  22.       Caption         =   "Graph"
  23.       Height          =   495
  24.       Left            =   120
  25.       TabIndex        =   13
  26.       Top             =   2400
  27.       Width           =   1215
  28.    End
  29.    Begin VB.TextBox StepText 
  30.       Height          =   285
  31.       Left            =   600
  32.       TabIndex        =   12
  33.       Text            =   "0.5"
  34.       Top             =   1920
  35.       Width           =   735
  36.    End
  37.    Begin VB.TextBox XmaxText 
  38.       Height          =   285
  39.       Left            =   600
  40.       TabIndex        =   10
  41.       Text            =   "10"
  42.       Top             =   1560
  43.       Width           =   735
  44.    End
  45.    Begin VB.TextBox XminText 
  46.       Height          =   285
  47.       Left            =   600
  48.       TabIndex        =   8
  49.       Text            =   "0"
  50.       Top             =   1200
  51.       Width           =   735
  52.    End
  53.    Begin VB.TextBox bText 
  54.       Height          =   285
  55.       Left            =   600
  56.       TabIndex        =   6
  57.       Text            =   "30"
  58.       Top             =   840
  59.       Width           =   735
  60.    End
  61.    Begin VB.TextBox NText 
  62.       Height          =   285
  63.       Left            =   600
  64.       TabIndex        =   4
  65.       Text            =   "5"
  66.       Top             =   480
  67.       Width           =   735
  68.    End
  69.    Begin VB.TextBox MText 
  70.       Height          =   285
  71.       Left            =   600
  72.       TabIndex        =   2
  73.       Text            =   "20"
  74.       Top             =   120
  75.       Width           =   735
  76.    End
  77.    Begin VB.Label Label1 
  78.       AutoSize        =   -1  'True
  79.       Caption         =   "Step"
  80.       Height          =   195
  81.       Index           =   5
  82.       Left            =   120
  83.       TabIndex        =   11
  84.       Top             =   1920
  85.       Width           =   330
  86.    End
  87.    Begin VB.Label Label1 
  88.       AutoSize        =   -1  'True
  89.       Caption         =   "Xmax"
  90.       Height          =   195
  91.       Index           =   4
  92.       Left            =   120
  93.       TabIndex        =   9
  94.       Top             =   1560
  95.       Width           =   390
  96.    End
  97.    Begin VB.Label Label1 
  98.       AutoSize        =   -1  'True
  99.       Caption         =   "Xmin"
  100.       Height          =   195
  101.       Index           =   3
  102.       Left            =   120
  103.       TabIndex        =   7
  104.       Top             =   1200
  105.       Width           =   345
  106.    End
  107.    Begin VB.Label Label1 
  108.       AutoSize        =   -1  'True
  109.       Caption         =   "b"
  110.       Height          =   195
  111.       Index           =   2
  112.       Left            =   360
  113.       TabIndex        =   5
  114.       Top             =   840
  115.       Width           =   90
  116.    End
  117.    Begin VB.Label Label1 
  118.       AutoSize        =   -1  'True
  119.       Caption         =   "N"
  120.       Height          =   195
  121.       Index           =   1
  122.       Left            =   360
  123.       TabIndex        =   3
  124.       Top             =   480
  125.       Width           =   120
  126.    End
  127.    Begin VB.Label Label1 
  128.       AutoSize        =   -1  'True
  129.       Caption         =   "M"
  130.       Height          =   195
  131.       Index           =   0
  132.       Left            =   360
  133.       TabIndex        =   1
  134.       Top             =   120
  135.       Width           =   135
  136.    End
  137. Attribute VB_Name = "Form1"
  138. Attribute VB_GlobalNameSpace = False
  139. Attribute VB_Creatable = False
  140. Attribute VB_PredeclaredId = True
  141. Attribute VB_Exposed = False
  142. Option Explicit
  143. Private Sub CmdGraph_Click()
  144. Dim M As Single
  145. Dim N As Single
  146. Dim b As Single
  147. Dim xmin As Single
  148. Dim xmax As Single
  149. Dim xstep As Single
  150. Dim X As Single
  151. Dim values() As Single
  152. Dim i As Integer
  153. Dim num_x As Integer
  154.     M = CSng(MText.Text)
  155.     N = CSng(NText.Text)
  156.     b = CSng(bText.Text)
  157.     xmin = CSng(XminText.Text)
  158.     xmax = CSng(XmaxText.Text)
  159.     xstep = CSng(StepText.Text)
  160.     num_x = (xmax - xmin) / xstep
  161.     ReDim values(1 To num_x, 1 To 2)
  162.         
  163.     ' Compute the data values.
  164.     X = xmin
  165.     For i = 1 To num_x
  166.         values(i, 1) = M * X + b
  167.         values(i, 2) = N * X ^ 2 - M * X + b
  168.         X = X + xstep
  169.     Next i
  170.     ' Send the data to the chart.
  171.     Chart1.RowCount = 2
  172.     Chart1.ColumnCount = num_x
  173.     Chart1.ChartData = values
  174.     Chart1.chartType = VtChChartType2dLine
  175.     ' Create the legend.
  176.     With Chart1.Legend
  177.         .Location.Visible = True
  178.         .Location.LocationType = VtChLocationTypeRight
  179.         .TextLayout.HorzAlignment = _
  180.             VtHorizontalAlignmentRight
  181.     End With
  182.     ' Set the legend text for the series.
  183.     Chart1.Plot.SeriesCollection(1).LegendText = "Straight Line"
  184.     Chart1.Plot.SeriesCollection(2).LegendText = "Quadratic"
  185. End Sub
  186. Private Sub Form_Load()
  187.     CmdGraph_Click
  188. End Sub
  189.